jQuery(function($) {
	//loadData();
	
});
function changeChongzhiNum(obj){
	obj.value=obj.value.replace(/[^-\d]/g,'')
	var count = obj.value;
	if(count == "" || count == "0"){
		parent.window.$("#promptTxt").html("请输入正确的金币数量");
	}else if(count > 0){
		parent.window.$("#promptTxt").html("你好，您将给"+parent.window.$("#chongzhiDialog_userId").html()+"账户【充值】"+count+"分");
	}else if(count< 0){
		parent.window.$("#promptTxt").html("你好，您将给"+parent.window.$("#chongzhiDialog_userId").html()+"账户【出库】"+-count+"分");
	}
}
function openChargeDialog(userId,goldCoinCount){
	$("#chongzhiDialog_userId").html(userId);
	$("#chongzhiDialog_goldCoinCount").html(goldCoinCount);
    var count = $("#chongzhi_num").val();
    if(count!=null){
        $("#promptTxt").html("你好，您将给"+userId+"账户【充值】1分");
        $("#chongzhi_num").attr("onkeyup",window.frameElement.id+".contentWindow.changeChongzhiNum(this)");
    }
	parent.window.Index.dialog({
		resizable: false,
		dialogClass: "no-close",
		width: '620',
		context:$("#chongzhiDialog").html(),
		modal: true,
		title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-rmb yellow'></i> 玩家充值</h4></div>",
		title_html: true,
		buttons: [
			{
				html: "<i class='ace-icon glyphicon glyphicon-ok bigger-110'></i>&nbsp; 保存",
				"class" : "btn btn-primary btn-minier",
				click: function() {
                    count = parent.window.$("#chongzhi_num").val();;
                    if(count == undefined){
                        count = '';
                    }
                    var goldLv = parent.window.$("#goldLv").val();
                    if(goldLv == undefined){
                        goldLv = '';
                    }
                    if((count == '') && (goldLv == '')){
                        return;
                    }
					$.ajax({
						type:"POST",
						url:ctx+"/admin/usermanager/chargeJBS",
						data:"userId="+userId+"&count="+count+"&goldLv="+goldLv,
						cache:false,
						success:function(data){
                            if(data.code == 0){
                                alert(data.msg);
                            }else {
                                refreshPage();
                				alert("成功!");
                            }
						}
					});
					parent.window.$( this ).dialog( "close" );
				}
			}
			,
			{
				html: "<i class='ace-icon glyphicon glyphicon-remove bigger-110'></i>&nbsp; 取消",
				"class" : "btn btn-minier",
				click: function() {
					parent.window.$( this ).dialog( "close" );
				}
			}
		]
	});
}
function loadData(){
	var data = $("#playerQueryFOrm").serialize();
	if(!data && initAgentId){
		data = "agentId="+initAgentId;
	}
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#context").html(data);
		}
	});
}
var returnTop = function(){
	initUserId = null;
	$('#queryInputAgentId').val('');
	refreshPage();
}

function setVip(userId,vip){
	var str=vip==1?"是否确定设置id为：'"+userId+"'为VIP？":"是否确定取消id为：'"+userId+"'的VIP？"
	if(confirm(str)){
		$.ajax({
			type:"POST",
			url:ctx + "/admin/usermanager/userVip",
			data:"userId="+userId+"&vip="+vip,
			cache:false,
			success:function(data){
				 if(data.code == 0){
                     alert(data.msg);
                 }else {
                     refreshPage();
     				alert("成功!");
                 }
			}
		});
	}
}


function setNullity(userId,nullity){
	var str=nullity==1?"是否确定封停id为：'"+userId+"'的玩家？":"是否确定解封id为：'"+userId+"'的玩家？"
	if(confirm(str)){
		$.ajax({
			type:"POST",
			url:ctx + "/admin/usermanager/setNullity",
			data:"userId="+userId+"&nullity="+nullity,
			cache:false,
			success:function(data){
				 if(data.code == 0){
                     alert(data.msg);
                 }else {
                     refreshPage();
     				alert("成功!");
                 }
			}
		});
	}
}
